//
//  NSString+NormalRegex.m
//  ZZFUCComponent
//
//  Created by quheng on 2017/8/29.
//  Copyright © 2017年 quheng. All rights reserved.
//

#import "NSString+NormalRegex.h"

@implementation NSString (NormalRegex)

/*邮箱验证 MODIFIED BY HELENSONG*/
+ (BOOL)isValidateEmail:(NSString *)email{
    
    NSString *emailRegex   = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
    return [emailTest evaluateWithObject:email];
}

/*手机号码验证 MODIFIED BY HELENSONG*/
+ (BOOL)isValidateMobile:(NSString *)mobile{
    
    //手机号以13， 15，18开头，八个 \d 数字字符
    NSString *phoneRegex   = @"^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0-9])|(17[0-9]))\\d{8}$";
    NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
    return [phoneTest evaluateWithObject:mobile];
}

/*车牌号验证 MODIFIED BY HELENSONG*/

+ (BOOL)isValidateCarNo:(NSString *)carNo{
    
    NSString *carRegex   = @"^[\u4e00-\u9fa5][a-zA-Z][0-9a-zA-Z]{5}[\u4e00-\u9fa5]?$";
    NSPredicate *carTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",carRegex];
    return [carTest evaluateWithObject:carNo];
}


+ (BOOL)isValidatePassword:(NSString *)password{

    NSString *regex   = @"^[a-zA-Z0-9._-]{6,20}$";
    NSPredicate *carTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
    return [carTest evaluateWithObject:password];
}


+ (BOOL)isValidateNickName:(NSString *)nickName{
    
    NSString *regex   = @"^[-_a-zA-Z0-9\u4e00-\u9fa5]{2,11}$";
    NSPredicate *carTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
    return [carTest evaluateWithObject:nickName];



}

@end
